import xadmin

from .models import ShoppingCart, OrderInfo, OrderGoods


class ShoppingCartAdmin(object):
    list_display = ["user", "goods", "nums", ]


class OrderInfoAdmin(object):
    list_display = ["user", "order_sn", "trade_no", "pay_status", "post_script", "order_mount",
                    "order_mount", "pay_time", "add_time"]
    # 查看订单的时候内置一个订单详情
    class OrderGoodsInline(object):
        model = OrderGoods  # 与Ordergoods进行关联
        exclude = ['add_time', ] # 除了add_time其他的都显示
        extra = 1   # 额外的表格是一个
        style = 'tab'

    inlines = [OrderGoodsInline, ]


xadmin.site.register(ShoppingCart, ShoppingCartAdmin)
xadmin.site.register(OrderInfo, OrderInfoAdmin)
